package com.example.mobile2032021606168xmy0617homework;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private Button btnMainAdd;
    private RecyclerView rvMainUsers;
    private List<Users> list=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        btnMainAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this,ShowDataActivity.class);
                startActivity(intent);
            }
        });
//        list.add(new Users(1,"崔胜贤","汽车工程师",3500));
//        list.add(new Users(2,"东永裴","汽车工人",3200));
        list=new MyDataAdapter().QueryAll(this);
        rvMainUsers.setAdapter(new UsersRViewAdapter(list));
    }

    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        btnMainAdd = (Button) findViewById(R.id.btn_main_add);
        rvMainUsers = (RecyclerView) findViewById(R.id.rv_main_users);
        rvMainUsers.setLayoutManager(new LinearLayoutManager(this));
    }
}